﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucVinamilkDetail.ascx.cs" Inherits="Admin_usercontrols_ucVinamilkDetail" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%@ Register Assembly="INNO.WebControls" Namespace="INNO.WebControls" TagPrefix="inno" %>
<script type="text/javascript" src="http://www.vietbando.com/maps/API/VBDMapAPI.js?key=e7vjH+pgQHuSyV75dwG6ho5iBCsznKyH"></script>
<%--e7vjH+pgQHuSyV75dwG6ho5iBCsznKyH--%>

<input id="notselect" type="hidden" value='<%=msg.GetMessage("ERR-000007")%>' />
<input id="deleteconfirm" type="hidden" value='<%=msg.GetMessage("ERR-000008")%>' />
<input id="hdDateFormat" type="hidden" value="<%= CurrentPage.Language%>" />
<div id="page-content">
    <div class="container">
        <div class="box-headerdetail"> 
            <asp:Label ID="lblBoxHeader" runat="server" Text="Thêm / Chỉnh sửa"></asp:Label>
        </div>
        <div class="box">
            <table cellpadding="0" cellspacing="0" width="100%">
                <tr valign="top">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td colspan="2">
                        <asp:ValidationSummary ID="valError" runat="server" EnableClientScript="False" />
                        <asp:CustomValidator ID="SaveValidate" runat="server" Display="None" CssClass="FormStyle"
                            ErrorMessage="" />
                    </td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Vị trí" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td></td>
                    <td colspan="2">
                        <div id="container" style="width: 100%; height: 300px; position: relative"></div>
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td style="width: 100px">
                        <asp:HiddenField ID="hdLa" runat="server" Value="10,7765344" />
                        <asp:HiddenField ID="hdLo" runat="server" Value="106,700999" />
                        <asp:HiddenField ID="hdVinamilkID" runat="server" />
                        <asp:Label ID="Label2" runat="server" Text="Thuộc khu vực" CssClass="Caption"></asp:Label>
                    </td>
                    <td class="tdEmpty"></td>
                    <td class="Require"></td>
                    <td colspan="2">
                        <asp:HiddenField ID="hdProvinceID" runat="server" />
                        <asp:DropDownList ID="dropProvince" runat="server" DataSourceID="ObjectDataSource1"
                            DataTextField="Name" DataValueField="ProvinceID" OnDataBound="DropProvinceDataBound">
                        </asp:DropDownList>
                        &nbsp;&nbsp;&nbsp; Tạo độ La&nbsp;
                        <asp:TextBox ID="txtLa" runat="server" Width="100px" MaxLength="500"></asp:TextBox>
                        &nbsp;&nbsp; Tạo độ Lo&nbsp;
                        <asp:TextBox ID="txtLo" runat="server" Width="100px" MaxLength="500"></asp:TextBox>
                        &nbsp;<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OnObjectCreating="ObjectDataSource1ObjectCreating"
                            SelectMethod="GetAllProvinceForGridView" TypeName="Vinamilk.BLL.v_ProvinceBLL"></asp:ObjectDataSource>
                    </td>
                </tr>
                <tr>
                    <td colspan="3"></td>
                    <td>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="dropProvince"
                            Display="Dynamic" ErrorMessage="Bạn phải chọn khu vực" InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                    <td></td>
                </tr>
                 <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label4" runat="server" Text="Loại của hàng" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td class="Require"></td>
                    <td colspan="2">
                        <asp:DropDownList ID="dropVinamilkType" runat="server" DataSourceID="ObjectDataSource2"
                            DataTextField="VinamilkTypeName" DataValueField="VinamilkTypeID" OnDataBound="dropVinamilkType_DataBound" >
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OnObjectCreating="ObjectDataSource2_ObjectCreating"
                            SelectMethod="GetAllVinamilkTypeForGridView" TypeName="Vinamilk.BLL.v_VinamilkTypeBLL"></asp:ObjectDataSource>
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="dropVinamilkType"
                            Display="Dynamic" ErrorMessage="Bạn phải chọn của hành" InitialValue="-1"></asp:RequiredFieldValidator>
                    </td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label3" runat="server" Text="Tên Vinamilk" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td class="Require"></td>
                    <td colspan="2">
                        <asp:TextBox ID="txtTitle" runat="server" Width="100%" MaxLength="500"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td colspan="3"></td>
                    <td colspan="2">
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic"
                            ControlToValidate="txtTitle" ErrorMessage="Hãy nhập dữ liệu"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label10" runat="server" Text="Kích hoạt" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td class="Require"></td>
                    <td colspan="2">
                        <asp:CheckBox ID="cbxIsActive" runat="server" />
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label9" runat="server" Text="Địa chỉ" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td></td>
                    <td colspan="2">
                        <asp:TextBox ID="txtAddress" runat="server" Width="100%"></asp:TextBox>
                    </td>
                </tr>
                 <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label6" runat="server" Text="Số tiền bán được" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td></td>
                    <td colspan="2">
                        <inno:NumericTextBox ID="txtTotalMoney" runat="server" Alignment="Left" Width="100%"></inno:NumericTextBox>
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:Label ID="Label5" runat="server" Text="Chi tiết" CssClass="Caption"></asp:Label>
                    </td>
                    <td></td>
                    <td></td>
                    <td colspan="2">
                        <CKEditor:CKEditorControl ToolbarCanCollapse="true" ID="FCKContent" runat="server" Height="100" BasePath="~/ckeditor"></CKEditor:CKEditorControl>
                    </td>
                </tr>
                <tr class="trEmpty">
                    <td colspan="3"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr valign="top">
                    <td align="right" colspan="5">
                        <asp:Button ID="btnSave" runat="server" CssClass="button" OnClick="BtnSaveClick" OnClientClick="return CheckSave();"
                            Text="Lưu" />
                        <asp:Button ID="btnSaveAndNew" runat="server" CssClass="button" OnClick="BtnSaveAndNewClick"
                            Text="Lưu & Tạo mới" />
                        <asp:Button ID="btnCancelAdd" runat="server" CausesValidation="False" CssClass="button"
                            OnClick="BtnCancelAddClick" Text="Ðóng" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<script>
    function MyControl(pt) {
        this.initialize = initialize;
        this.getDefaultPosition = getDefaultPosition;
        this.vType = vType;

        function initialize(map) {
            this.id = 'MyControl';
            var divcontainer = document.createElement("div");
            divcontainer.id = 'MyControl';
            divcontainer.style.position = 'relative';
            divcontainer.style.border = "0px solid black";

            var divZoomIn = document.createElement("div");
            divZoomIn.id = 'divHome';
            divZoomIn.style.cssFloat = 'right';
            divZoomIn.style.right = '2px';
            divZoomIn.style.position = 'absolute';
            divZoomIn.style.cursor = 'pointer';
            divcontainer.appendChild(divZoomIn);
            divZoomIn.innerHTML = "<img src='http://maps.vietbando.com/maps/biz/images/go_home.png' alt='Trở về' title='Trở về vị trí ban đầu' />";
            VEvent.addDOMListener(divZoomIn, "click", function () {
                var pt = new VLatLng(parseFloat($('#<%= hdLa.ClientID %>').val().replace(',', '.')), parseFloat($('#<%= hdLo.ClientID %>').val().replace(',', '.')));
                marker.setPoint(pt);
                $('#<%= txtLa.ClientID %>').val(marker.latlngs.latitude);
                $('#<%= txtLo.ClientID %>').val(marker.latlngs.longitude);
                map.setCenter(pt, 15);
            });

            map.getContainer().appendChild(divcontainer);
        }

        function getDefaultPosition() {
            var defaultpos = new VControlPosition(V_ANCHOR_TOP_LEFT, new VSize(0, 0));
            return defaultpos;
        }

        function vType() {
            return 'MyControl';
        }
    }
    MyControl.prototype = new VControl();
    var Controlnew2 = null;
    var map = new VMap(document.getElementById('container'));
    var pt = new VLatLng(parseFloat($('#<%= hdLa.ClientID %>').val().replace(',', '.')), parseFloat($('#<%= hdLo.ClientID %>').val().replace(',', '.')));
    map.setCenter(pt, 15);
    mopt = new VMarkerOptions(new VIcon("http://www.vietbando.com/Maps/images/mymap_icon/point-1.gif", new VSize(32, 32)));
    var marker = new VMarker(pt, mopt);
    marker.enableDragging();
    map.addOverlay(marker);
    Controlnew2 = new MyControl(pt);
    map.addControl(new VScaleControl());
    map.addControl(new VLargeMapControl());
    map.addControl(Controlnew2);
    AddListeners();

    $("#<%= txtLa.ClientID %>").keyup(function () {
        var pt = new VLatLng($(this).val(), $("#<%= txtLo.ClientID %>").val());
        marker.setPoint(pt);
        map.setCenter(pt, 15);
    });

    $("#<%= txtLo.ClientID %>").keyup(function () {
        var pt = new VLatLng($("#<%= txtLa.ClientID %>").val(), $(this).val());
        marker.setPoint(pt);
        map.setCenter(pt, 15);
    });


    function CheckSave() {
        $('#<%= hdLa.ClientID %>').val(marker.latlngs.latitude);
        $('#<%= hdLo.ClientID %>').val(marker.latlngs.longitude);
        return true;
    }

    function AddListeners() {
        VEvent.addListener(marker, "dragend", function () {
            $('#<%= txtLa.ClientID %>').val(marker.latlngs.latitude);
            $('#<%= txtLo.ClientID %>').val(marker.latlngs.longitude);
        });
    }

</script>
